package com.hyacinth.serialize;

import com.hyacinth.serialize.impl.*;

/**
 * 创建序列化实例
 * @author zhangfb
 * @version 1.0.0.1
 * @since JDK 1.8
 */
public class SerializerFactory {

    /**
     * 创建序列化实例
     * @param algorithm 序列化算法
     * @return 序列化实例
     */
    public static Serializer instance(SerializerAlgorithm algorithm) {
        switch(algorithm) {
            case JAVA:
                return new JavaSerializer();
            case JSON:
                return new JSONSerializer();
            case KRYO:
                return new KryoSerializer();
            case FST:
                return new FSTSerializer();
            case PROTOSTUFF:
                return new ProtostuffSerializer();
            default:
                return Serializer.DEFAULT;
        }
    }
}
